<?php $self = 'self' . time() . rand(1, 10000); ?>
<style type="text/css">
    #ajaxAddTaskOperateForm .form-body .form-group {
        width: 50%;
        float: left;
    }

    #ajaxAddTaskOperateForm .form-body .form-group .col-xs-3 {
        width: 45%;
    }

    #ajaxAddTaskOperateForm .form-body .form-group .col-xs-4 {
        width: 45%;
    }

    .ECalendarBox {
        z-index: 100;
    }

    .ECalendarBox .currentdate h2 {
        margin-top: 0px;
    }

    .modal-dialog {
        width: 1280px;
    }

    td {
        text-align: center;
    }

    tr{
        line-height: 35px;
    }
    .modal_image_list .form-group {
        float: left;
        margin-top: 30px;
    }

    .modal_image_list img {
        float: left;
        margin-left: 30px;
    }
</style>
<link href="<?= image_url('/static/assets/global/css/ecalendar-style.css') ?>" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="<?= image_url('/static/js/Ecalendar.jquery.min.js') ?>"></script>
<?= form_open('', Array('class' => 'form-horizontal', 'role' => 'form', 'id' => 'ajaxViewOperateDetail', 'data-category-id' => $obj->id, 'name' => 'ajaxViewOperateDetail', 'onsubmit' => 'return submitForm()')) ?>
<div class="portlet-body form " id="<?php echo $self; ?>">
    <input type="hidden" id="update_time" name="update_time"
           value="<?= set_value('update_time', $user->update_time) ?>"/>
    <div class="form-body">
        <div class="table-scrollable">
            <table class="table table-hover table-bordered table-striped">
                <tr>
                    <td align="right" width="10%">测评记录ID：</td>
                    <td class="bold" width="15%"><?= $obj->id ?></td>
                    <td align="right" width="10%">任务ID：</td>
                    <td class="bold" width="15%"><?= $obj->task_id ?> - <a
                                href="<?= site_url('/tasks/task/view/' . $obj->task_id) ?>" target="_blank">查看</a></td>
                    <td align="right" width="10%">该付款类型：</td>
                    <td class="bold" width="15%"><?= IOSS_StaticConfig::$payTypeArray[$obj->payment_type] ?></td>
                    <td align="right" width="10%">创建时间：</td>
                    <td class="bold" width="15%"><?= date('Y-m-d H:i:s', $obj->create_time) ?></td>
                </tr>
                <tr>
                    <td align="right" width="10%">接单者：</td>
                    <td class="bold" width="15%"><?= $allReviewsAdmin[$obj->operator_id] ?></td>

                    <td align="right" width="10%">关联财务申请：</td>
                    <td class="bold" width="15%"><?= $obj->pay_request_id ?> - <a
                                href="<?= site_url('/finance/apply/detail/' . $obj->pay_request_id) ?>" target="_blank">查看</a>
                    </td>
                    <td align="right" width="10%">关联财务操作人：</td>
                    <td class="bold" width="15%"><?= $allFanaceAdmin[$obj->finace_id] ?></td>
                    <td align="right" width="10%">打款方式：</td>
                    <td class="bold"><?= IOSS_StaticConfig::getPayMethod($obj->pay_method)?IOSS_StaticConfig::getPayMethod($obj->pay_method): '未填'?></td>
                </tr>
                <tr>
                    <td align="right">买家下单号：</td>
                    <td class="bold"><?= $obj->order_no ?></td>

                    <td align="right">买家下单日期：</td>
                    <td class="bold"><?= $obj->buyer_order_time > 0 ? date('Y-m-d', $obj->buyer_order_time) : '未填写' ?></td>
                    <td align="right">买家付款日期：</td>
                    <td class="bold"><?= $obj->buyer_pay_time > 0 ? date('Y-m-d', $obj->buyer_pay_time) : '未填写' ?></td>
                    <td align="right"></td>
                    <td align="bold"></td>
                </tr>
                <tr>
                    <td align="right">买家付款币种：</td>
                    <td class="bold text-center"><?= IOSS_StaticConfig::getcoinTypeInfo($obj->buyer_pay_coin_type) ?></td>
                    <td align="right">买家付款方式：</td>
                    <td class="bold text-center"><?= IOSS_StaticConfig::getPayMethod($obj->pay_method) ?></td>
                    <td align="right">商品实价/运费：</td>
                    <td class="bold"><?= $obj->true_product_price > 0 ? number_format($obj->true_product_price, 2, '.', '') : '' ?>
                        / <?= $obj->yunfei > 0 ? number_format($obj->yunfei, 2) : '' ?></td>
                    <td align="right"></td>
                    <td align="bold"></td>
                </tr>
                <tr>
                    <td align="right">应付刷单费</td>
                    <td class="bold"><?= $obj->true_shuadan_amount > 0 ? number_format($obj->true_shuadan_amount, 2, '.', '') : '' ?></td>
                    <td align="right">买家收款币种：</td>
                    <td class="bold"><?= IOSS_StaticConfig::getcoinTypeInfo($obj->coin_type) ? IOSS_StaticConfig::getcoinTypeInfo($obj->coin_type) : '未填' ?></td>
                    <td align="right">评论链接：</td>
                    <td class="bold"><?php if ($obj->comment_link): ?><a href="<?= $obj->comment_link ?>" target="_blank" class="btn blue">查看</a><?php else: ?>未填<?php endif; ?></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr>
                    <td align="right">公司实际刷单成本</td>
                    <td class="bold"><?= $obj->true_company_cost > 0 ? number_format($obj->true_company_cost, 2, '.', '') : '' ?></td>
                    <td align="right">公司成本对rmb汇率：</td>
                    <td class="bold"><?= $obj->true_company_cost_rate > 0 ? number_format($obj->true_company_cost_rate, 5, '.', '') : '' ?></td>
                    <td></td>
                    <td>测评类型：</td>
                    <td><?= $obj->ceping_type == 0?'未标记':($obj->ceping_type == 1?'销量':'测评'); ?></td>
                    <td></td>
                </tr>
                <tr>
                    <td align="right">买家收款账号：</td>
                    <?php if ($obj->operator_id == $this->_user->id || in_array($this->_user->role_id,[7,8])): ?>
                        <td class="bold"><?= $obj->pay_account ?></td>
                    <?php else: ?>
                        <td class="bold">******</td>
                    <?php endif; ?>
                    <td align="right">买家联系方式：</td>
                    <?php if ($obj->operator_id == $this->_user->id || in_array($this->_user->role_id,[7,8])): ?>
                        <td class="bold"><?= $obj->contact ?></td>
                    <?php else: ?>
                        <td class="bold">******</td>
                    <?php endif; ?>
                    <td align="right">买家佣金：</td>
                    <td class="bold"><?= $obj->commission > 0 ? number_format($obj->commission, 3, '.', '') .'('.(IOSS_StaticConfig::getcoinTypeInfo($obj->coin_type) ? IOSS_StaticConfig::getcoinTypeInfo($obj->coin_type) : '').')' : '未填' ?></td>
                    <td align="right">买家收款对RMB汇率：</td>
                    <td class="bold"><?= $obj->rate_rmb > 0 ? $obj->rate_rmb : '未填' ?></td>

                </tr>
                <tr>
                    <td align="right">中介收款账号：</td>
                    <?php if ($obj->operator_id == $this->_user->id || in_array($this->_user->role_id,[7,8])): ?>
                        <td class="bold"><?= $obj->intror_pay_account ?></td>
                    <?php else: ?>
                        <td class="bold">******</td>
                    <?php endif; ?>
                    <td align="right">中介联系方式：</td>
                    <?php if ($obj->operator_id == $this->_user->id || in_array($this->_user->role_id,[7,8])): ?>
                        <td class="bold"><?= $obj->intror_contact ?></td>
                    <?php else: ?>
                        <td class="bold">******</td>
                    <?php endif; ?>
                    <td align="right">中介要求中介费：</td>
                    <td class="bold"><?= $obj->intror_commission > 0 ? number_format($obj->intror_commission, 3, '.', '').'('.(IOSS_StaticConfig::getcoinTypeInfo($obj->intror_coin_type) ? IOSS_StaticConfig::getcoinTypeInfo($obj->intror_coin_type) : '').')' : '未填' ?></td>
                    <td align="right">中介费对RMB汇率：</td>
                    <td class="bold"><?= $obj->intror_rate_rmb > 0 ? $obj->intror_rate_rmb : '未填' ?></td>
                </tr>
                <tr>
                    <td align="right">备注：</td>
                    <td colspan="7" class="bold" style="text-align: left">
                        <textarea style="width: 100%;" name="remark" cols="60" rows="4"><?= $obj->remark ?></textarea>
                    </td>
                </tr>
                <tr>
                    <td align="right">截图凭证：</td>
                    <td colspan="7" class="bold modal_image_list">
                        <?php if ($obj->add_image): ?>
                            <?php if (strstr($obj->add_image, 'doc') || strstr($obj->add_image, 'xls')): ?>
                                <a href="<?= image_url('/' . $obj->add_image) ?>">
                                    <img title="<?= $obj->add_image ?>" src="/static/img/docx.png" width="auto"
                                         height="80"/>
                                </a>

                            <?php elseif (strstr($obj->add_image, 'zip') || strstr($obj->add_image, 'rar')): ?>
                                <a href="<?= image_url('/' . $obj->add_image) ?>">
                                    <img title="<?= $obj->add_image ?>" src="/static/img/zip.png" width="auto"
                                         height="80"/>
                                </a>
                            <?php else: ?>
                                <img class="img-rounded" src="<?= image_url($obj->add_image) ?>" width="auto"
                                     height="80"/>
                            <?php endif; ?>
                        <?php else: ?>
                            <?= edit_form_uploader('add_image_' . $obj->id, set_uploader('add_image', $obj->add_image), '') ?>
                        <?php endif; ?>
                        <?php if ($obj->add_image_1): ?>
                            <?php if (strstr($obj->add_image_1, 'doc') || strstr($obj->add_image_1, 'xls')): ?>
                                <a href="<?= image_url('/' . $obj->add_image_1) ?>">
                                    <img title="<?= $obj->add_image_1 ?>" src="/static/img/docx.png" width="auto" height="80"/>
                                </a>

                            <?php elseif (strstr($obj->add_image_1, 'zip') || strstr($obj->add_image_1, 'rar')): ?>
                                <a href="<?= image_url('/' . $obj->add_image_1) ?>">
                                    <img title="<?= $obj->add_image_1 ?>" src="/static/img/zip.png" width="auto"
                                         height="80"/>
                                </a>
                            <?php else: ?>
                                <img class="img-rounded" src="<?= image_url($obj->add_image_1) ?>" width="auto"
                                     height="80"/>
                            <?php endif; ?>
                        <?php else: ?>
                            <?= edit_form_uploader('add_image_1_' . $obj->id, set_uploader('add_image_1', $obj->add_image_1), '') ?>
                        <?php endif; ?>
                        <?php if ($obj->add_image_2): ?>
                            <?php if (strstr($obj->add_image_2, 'doc') || strstr($obj->add_image_2, 'xls')): ?>
                                <a href="<?= image_url('/' . $obj->add_image_2) ?>">
                                    <img title="<?= $obj->add_image_2 ?>" src="/static/img/docx.png" width="auto"
                                         height="80"/>
                                </a>

                            <?php elseif (strstr($obj->add_image_2, 'zip') || strstr($obj->add_image_2, 'rar')): ?>
                                <a href="<?= image_url('/' . $obj->add_image_2) ?>">
                                    <img title="<?= $obj->add_image_2 ?>" src="/static/img/zip.png" width="auto"
                                         height="80"/>
                                </a>
                            <?php else: ?>
                                <img class="img-rounded" src="<?= image_url($obj->add_image_2) ?>" width="auto"
                                     height="80"/>
                            <?php endif; ?>
                        <?php else: ?>
                            <?= edit_form_uploader('add_image_2_' . $obj->id, set_uploader('add_image_2', $obj->add_image_2), '') ?>
                        <?php endif; ?>
                        <?php if ($obj->add_image_3): ?>
                            <?php if(strstr($obj->add_image_3,'doc')  || strstr($obj->add_image_3,'xls')):?>
                                <a href="<?=image_url('/'.$obj->add_image_3)?>">
                                    <img title="<?=$obj->add_image_3?>" src="/static/img/docx.png" width="auto" height="80"/>
                                </a>

                            <?php elseif (strstr($obj->add_image_3,'zip') || strstr($obj->add_image_3,'rar')):?>
                                <a href="<?=image_url('/'.$obj->add_image_3)?>">
                                    <img title="<?=$obj->add_image_3?>" src="/static/img/zip.png" width="auto" height="80"/>
                                </a>
                            <?php else: ?>
                                <img class="img-rounded" src="<?=image_url($obj->add_image_3)?>" width="auto" height="80"/>
                            <?php endif;?>
                        <?php else: ?>
                            <?= edit_form_uploader('add_image_3_' . $obj->id, set_uploader('add_image_3', $obj->add_image_3), '') ?>
                        <?php endif; ?>
                        <?php if ($obj->add_image_4): ?>
                            <?php if(strstr($obj->add_image_4,'doc')  || strstr($obj->add_image_4,'xls')):?>
                                <a href="<?=image_url('/'.$obj->add_image_4)?>">
                                    <img title="<?=$obj->add_image_4?>" src="/static/img/docx.png" width="auto" height="80"/>
                                </a>

                            <?php elseif (strstr($obj->add_image_4,'zip') || strstr($obj->add_image_4,'rar')):?>
                                <a href="<?=image_url('/'.$obj->add_image_4)?>">
                                    <img title="<?=$obj->add_image_4?>" src="/static/img/zip.png" width="auto" height="80"/>
                                </a>
                            <?php else: ?>
                                <img class="img-rounded" src="<?=image_url($obj->add_image_4)?>" width="auto" height="80"/>
                            <?php endif;?>
                        <?php else: ?>
                            <?= edit_form_uploader('add_image_4_' . $obj->id, set_uploader('add_image_4', $obj->add_image_4), '') ?>
                        <?php endif; ?>
                        <?php if ($obj->add_image_5): ?>
                            <?php if(strstr($obj->add_image_5,'doc')  || strstr($obj->add_image_5,'xls')):?>
                                <a href="<?=image_url('/'.$obj->add_image_5)?>">
                                    <img title="<?=$obj->add_image_5?>" src="/static/img/docx.png" width="auto" height="80"/>
                                </a>

                            <?php elseif (strstr($obj->add_image_5,'zip') || strstr($obj->add_image_5,'rar')):?>
                                <a href="<?=image_url('/'.$obj->add_image_5)?>">
                                    <img title="<?=$obj->add_image_5?>" src="/static/img/zip.png" width="auto" height="80"/>
                                </a>
                            <?php else: ?>
                                <img class="img-rounded" src="<?=image_url($obj->add_image_5)?>" width="auto" height="80"/>
                            <?php endif;?>
                        <?php else: ?>
                            <?= edit_form_uploader('add_image_5_' . $obj->id, set_uploader('add_image_5', $obj->add_image_5), '') ?>
                        <?php endif; ?>
                    </td>
                </tr>
                <?php if (!in_array($this->_user->role_id, array(2, 4, 7))): ?>
                    <tr>
                        <td align="right">状态：</td>
                        <td colspan="7" class="bold modal_image_list">
                            <?= MTaskOperate::getState()[$obj->status]; ?>
                        </td>
                    </tr>
                <?php endif; ?>
            </table>
        </div>

    </div>
    <div style="clear:both;"></div>

    <?php
    //2，4是销售，7是财务
    //0,1,12,2 状态是未经财务改动的状态，此时销售都可改
    if (in_array($this->_user->role_id, array()) && in_array($obj->status, array(0, 1, 12, 2))): ?>
        <?= edit_form_radio_list('status', array('1' => '不通过（如单号、金额有误）', '2' => '通过'), set_value('status', $obj->status ? $obj->status : '1'), '销售审核状态') ?>
        <?= edit_form_radio_list('ceping_type', array('0' => '未标定', '1' => '销量', '2' => '测评'), set_value('ceping_type', $obj->ceping_type), '销售审核类型') ?>
        <div class="modal-footer">
            <button type="button" data-dismiss="modal" class="btn default">关闭</button>
            <button type="submit" class="btn btn-primary">提交审核状态</button>
        </div>
    <?php endif; ?>

    <?php if (in_array($this->_user->role_id, array(7,8)) && in_array($obj->status, array(3,5))): ?>
        <input type="hidden" name="ceping_type" value="<?= $obj->ceping_type ?>">
        <?= edit_form_radio_list('status', array('4' => '不通过（如收款账号、金额有误）', '5' => '通过'), set_value('status', $obj->status ? $obj->status : '4'), '财务审核状态') ?>
        <div class="modal-footer">
            <button type="button" data-dismiss="modal" class="btn default">关闭</button>
            <button type="submit" class="btn btn-primary">提交审核状态</button>
        </div>
    <?php endif; ?>

    <?php if (!in_array($this->_user->role_id, array(2, 4, 7,8))): ?>
        <div class="modal-footer">
            <span style="padding-right:20px;color:#e20000;">只有任务审核联系人或财务处理者才可以审核更改状态</span>
            <button type="button" data-dismiss="modal" class="btn default">关闭</button>
        </div>
    <?php endif; ?>
</div>
<?= form_close() ?>
<script type="text/javascript">
    $(document).ready(function () {
        $('.img-rounded').zoomify();

        AjaxUploader.uploadTempUrl = "<?=site_url('/common/AjaxUpload/upload') . '/'  ?>";
        AjaxUploader.model_init(<?php echo $self?>);
    });

    function submitForm() {
        if (confirm('您确定要修改该任务操作记录的状态？')) {
            return true;
        } else {
            return false;
        }
    }
</script>

